-
Notifications
You must be signed in to change notification settings - Fork 307
Improve repository selection, based on prefixes in config and full image name #547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #547 +/- ##
==========================================
+ Coverage 65.76% 65.96% +0.20%
==========================================
Files 21 21
Lines 2039 2051 +12
==========================================
+ Hits 1341 1353 +12
Misses 569 569
Partials 129 129
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
…ull image name Signed-off-by: Viacheslav Sychov <[email protected]>
Signed-off-by: Viacheslav Sychov <[email protected]>
Also in this PR I fixed pipeline (linter didn't works), @jannfis can you review pls? |
Thanks @vsychov - this change is reasonable to me, and I'd like it to go in! I'll try to carve out some time for review really soon. |
Hello @jannfis, is it ok to be merged? |
Hello @jannfis , any updates on that? |
Hi guys, can it be merged? |
Hello, functionality is crucial to be able to have several container registries for different teams with different credentials. Is here any chance that it will be merged? |
// - If one or more custom certificates are stored for the repository, returns | ||
// a client with those certificates in the list of root CAs used to verify | ||
// the server's certificate. | ||
// - Otherwise (and on non-fatal errors), a default HTTP client is returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like only whitespace changes. I think we should avoid these changes.
func findRegistryEndpointByImage(img *image.ContainerImage) (ep *RegistryEndpoint) { | ||
log.Debugf("Try to find endpoint by image: %s/%s", img.RegistryURL, img.ImageName) | ||
registryLock.RLock() | ||
imgName := fmt.Sprintf("%s/%s", img.RegistryURL, img.ImageName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about moving line 187 to the first line of this func, and use var imgName
in log.Debugf(...)
?
} | ||
} | ||
|
||
registryLock.RUnlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving defer RUnlock()
to right after the RLock() function.
for _, registry := range registries { | ||
if (ep == nil && strings.HasPrefix(imgName, registry.RegistryPrefix)) || (strings.HasPrefix(imgName, registry.RegistryPrefix) && len(registry.RegistryPrefix) > len(ep.RegistryPrefix)) { | ||
log.Debugf("Selected registry: '%s' (last selection in log - final)", registry.RegistryName) | ||
ep = registry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it break after the first match?
@@ -343,7 +344,7 @@ func warmupImageCache(cfg *ImageUpdaterConfig) error { | |||
entries := 0 | |||
eps := registry.ConfiguredEndpoints() | |||
for _, ep := range eps { | |||
r, err := registry.GetRegistryEndpoint(ep) | |||
r, err := registry.GetRegistryEndpoint(&image.ContainerImage{RegistryURL: ep}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg/registry
has been moved to the sub-module registry-scanner
.
@vsychov sorry for the late response. I've added some comments above and please take a look. Registry-related types and operations have been moved to a sub-module |
Hello everyone,
This code solves a problem that occurs with DigitalOcean repositories when you have multiple repositories in different projects with different credentials.
For example:
Previously, image-updater ignored this configuration and only used "https://registry.digitalocean.com" because it could not find an exact repository match.
This PR fixes this problem so that the above configuration will work.